package com.njmaomao.gj.pyot.domain.model;

import org.apache.commons.lang3.StringUtils;

import java.util.Date;
import javax.persistence.*;
import java.io.Serializable;

/**
 * @author hh
 * @description (trading_refund_record)表实体类
 * @date 2019-03-13 14:47:40
 */
@Entity
@Table(name = "wechat_pay_refund_record")
public class RefundRecord implements Serializable {

    private static final long serialVersionUID = 519069166137234230L;

    /**
     * 唯一标识
     */
    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    /**
     * 订单号
     */
    @Column(name = "order_code")
    private String orderCode;

    /**
     * 退款单号
     */
    @Column(name = "refund_no")
    private String refundNo;

    /**
     * 来源系统
     */
    @Column(name = "from_system")
    private String fromSystem;

    /**
     * 支付平台退款单号
     */
    @Column(name = "refund_id")
    private String refundId;

    /**
     * 支付金额
     */
    @Column(name = "total_amount")
    private Integer totalAmount;

    /**
     * 退款金额
     */
    @Column(name = "refund_amount")
    private Integer refundAmount;

    /**
     * 货币类型
     */
    @Column(name = "refund_currency")
    private String refundCurrency;

    /**
     * 操作人
     */
    @Column(name = "operator")
    private String operator;

    /**
     * 状态,0已申请,1 退款成功,2，退款失败
     */
    @Column(name = "status")
    private Integer status;

    /**
     * 退款原因
     */
    @Column(name = "refund_desc")
    private String refundDesc;

    /**
     * 支付平台返回的退款消息
     */
    @Column(name = "msg")
    private String msg;

    /**
     * 创建退单时间
     */
    @Column(name = "create_time")
    private Date createTime;

    /**
     * 支付平台通知支付系统订单退款结果，支付系统将状态通知到指定url
     */
    @Column(name = "callback_url")
    private String callbackUrl;

    /**
     * 退单成功时间(退款成功回调时的时间)
     */
    @Column(name = "refund_time")
    private Date refundTime;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getOrderCode() {
        return orderCode;
    }

    public void setOrderCode(String orderCode) {
        this.orderCode = orderCode;
    }

    public String getRefundNo() {
        return refundNo;
    }

    public void setRefundNo(String refundNo) {
        this.refundNo = refundNo;
    }

    public String getFromSystem() {
        return fromSystem;
    }

    public void setFromSystem(String fromSystem) {
        this.fromSystem = fromSystem;
    }

    public String getRefundId() {
        return refundId;
    }

    public void setRefundId(String refundId) {
        this.refundId = refundId;
    }

    public Integer getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(Integer totalAmount) {
        this.totalAmount = totalAmount;
    }

    public Integer getRefundAmount() {
        return refundAmount;
    }

    public void setRefundAmount(Integer refundAmount) {
        this.refundAmount = refundAmount;
    }

    public String getRefundCurrency() {
        return refundCurrency;
    }

    public void setRefundCurrency(String refundCurrency) {
        this.refundCurrency = refundCurrency;
    }

    public String getOperator() {
        return operator;
    }

    public void setOperator(String operator) {
        this.operator = operator;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getRefundDesc() {
        return refundDesc;
    }

    public void setRefundDesc(String refundDesc) {
        this.refundDesc = refundDesc;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getCallbackUrl() {
        return callbackUrl;
    }

    public void setCallbackUrl(String callbackUrl) {
        this.callbackUrl = callbackUrl;
    }

    public Date getRefundTime() {
        return refundTime;
    }

    public void setRefundTime(Date refundTime) {
        this.refundTime = refundTime;
    }

    public boolean necessaryCallback(){
        return StringUtils.isNoneBlank(getCallbackUrl());
    }

    public enum Status{
        REFUNDING(0),REFUNDED(1),REFUNDFAIL(2);
        private int status;

        Status(int status) {
            this.status = status;
        }

        public int getStatus() {
            return status;
        }

    }
}